/*
*THIS CODE PRODUCES ALL THE RESULTS IN:
*"SCEPTICAL EMPLOYERS: EXPERIMENTAL EVIDENCE ON BIASED BELIEFS CONSTRAINING FIRM GROWTH"
*BY STEFANO A. CARIA AND PAOLO FALCO

THE CODE REQUIRES THE FOLLOWING DATASETS IN ORDER TO OPERATE:

wvs.dta (Stata Dataset) - PUBLICLY AVAILABLE DATA FROM THE WORLD VALUES SURVEY (2014) - https://www.worldvaluessurvey.org/wvs.jsp
wms.dta (Stata Dataset) - PUBLICLY AVAILABLE DATA FROM THE WORLD MANAGEMENT SURVEY - https://worldmanagementsurvey.org/
entrepreneurs.dta (Stata Dataset) - EXPERIMENTAL DATA ON ENTREPRENEURS' CHOICES IN THE MAIN EXPERIMENT CONDUCTED BY THE AUTHORS AND DOCUMENTED IN THE ARTICLE (VARIABLE LABELS INCLUDED IN THE DATASET)
workers.dta (Stata Dataset) - EXPERIMENTAL DATA ON WORKERS' CHOICES IN THE MAIN EXPERIMENT CONDUCTED BY THE AUTHORS AND DOCUMENTED IN THE ARTICLE (VARIABLE LABELS INCLUDED IN THE DATASET)
ethiopia_firm_survey.dta (Stata Dataset) - DATA FROM FIRM SURVEY CONDUCTED IN ETHIOPIA BY THE AUTHORS AND DOCUMENTED IN THE ARTICLE (VARIABLE LABELS INCLUDED IN THE DATASET)
*/

clear
set more off
set scheme s2mono

**********************************************************************************************************************************
*SET WORKING FOLDER (WHERE ALL THE DATASETS LISTED ABOVE SHOULD BE PLACED)
cd ""
**********************************************************************************************************************************

************************************
******** FIGURES *******************
************************************

************************************
******** FIGURE 1 ******************
************************************

clear
	
use "wvs.dta"

twoway (bar trust id if continent  == "Africa", color(white) lcolor(black) lwidth(vthin)) ///
       (bar trust id if continent == "Asia", color(black*.20) lcolor(black) lwidth(vvvthin))    ///
       (bar trust id if continent == "Europe", color(black*.20) lcolor(black) lwidth(medthick)) ///   
       (bar trust id if continent == "North America", color(black*.40)) ///
       (bar trust id if continent == "South America", color(black*.80)) ///
       (bar trust id if continent == "Oceania", color(black) ///
	   legend(order(1 "Africa" 2 "Asia" 3 "Europe" 4 "North America" 5 "South America" 6 "Oceania") row(2) size(small)) ///
	   xlabel(none) xtitle(" " "Countries", margin(medium)) ytitle("Percent of people who think" "others can be trusted", size(small) margin(small)) ///
	   text(13 4 "{bf:Ghana}", place(n)) ///
	   text(12 4 "|", place(s)) ///
	   text(11 4 "|", place(s)) ///
	   text(20 8 "Zimbabwe", place(n)) ///
	   text(18 8 "|", place(s)) ///
	   text(16 8 "|", place(s)) ///
	   text(-14 5 "Brazil", place(n)) ///
	   text(-2 5 "|", place(s)) ///
	   text(-1 5 "|", place(s)) ///
	   text(-14 16 "Turkey", place(n)) ///
	   text(-2 16 "|", place(s)) ///
	   text(-1 16 "|", place(s)) ///
	   text(-14 47 "Japan", place(n)) ///
	   text(-2 47 "|", place(s)) ///
	   text(-1 47 "|", place(s)) ///
	   text(73 59 "Sweden", place(n)) ///
	   text(72 59 "|", place(s)) ///
	   text(71 59 "|", place(s)) ///
	   text(34 36 "Pakistan", place(n)) ///
	   text(33 36 "|", place(s)) ///
	   text(32 36 "|", place(s)) ///
	   text(49 49 "United States", place(n)) ///
	   text(47 49 "|", place(s)) ///
	   text(46 49 "|", place(s)) ///
	   text(22 17 "Mexico", place(n)) ///
	   text(21 17 "|", place(s)) ///
	   text(20 17 "|", place(s)) ///
	   text(28 29 "Spain", place(n)) ///
	   text(27 29 "|", place(s)) ///
	   text(26 29 "|", place(s)) )
	
	graph export "MacroTrustDistributionNew.png", replace width(1600) height(1200)


************************************
******** FIGURE 2 ******************
************************************
		
use workers, clear
forval x=1(1)2 {
preserve
replace trustw`x' = trustw`x'*100
drop if Sample == "Women" | Sample == "Young" 
if `x' == 2 {
drop if Type == "Treatment 1" | Type == "Treatment 2"
}
collapse (mean) meantrustw = trustw`x' (sd) sdtrustw = trustw`x' (count) n = trustw`x'
generate hitrustw = meantrustw + invttail(n-1,0.025)*(sdtrustw / sqrt(n))
generate lotrustw = meantrustw - invttail(n-1,0.025)*(sdtrustw / sqrt(n))
ge round = `x'
gen type = 2
if `x' == 1 {
tempfile e_trustw_round1
save `e_trustw_round1', replace
}
if `x' == 2 {
tempfile e_trustw_round2
save `e_trustw_round2', replace
}
restore
}

use workers, clear
forval x=1(1)2 {
preserve
replace expect2 = . if t1 == 1 | t2 == 1 
replace expect`x' = expect`x'*10
drop if Sample == "Women" | Sample == "Young" 
if `x' == 2 {
drop if Type == "Treatment 1" | Type == "Treatment 2"
}
collapse (mean) meanexpect = expect`x' (sd) sdexpect = expect`x' (count) n = expect`x'
generate hiexpect = meanexpect + invttail(n-1,0.025)*(sdexpect / sqrt(n))
generate loexpect = meanexpect - invttail(n-1,0.025)*(sdexpect / sqrt(n))
ge round = `x'
gen type = 2
if `x' == 1 {
tempfile e_expect_round1
save `e_expect_round1', replace
}
if `x' == 2 {
tempfile e_expect_round2
save `e_expect_round2', replace
}
restore
}

use workers, clear
forval x=1(1)2 {
preserve
replace trustw`x' = trustw`x'*100
collapse (mean) meantrustw = trustw`x' (sd) sdtrustw = trustw`x' (count) n = trustw`x', by(Male)
generate hitrustw = meantrustw + invttail(n-1,0.025)*(sdtrustw / sqrt(n))
generate lotrustw = meantrustw - invttail(n-1,0.025)*(sdtrustw / sqrt(n))
ge round = `x'
if `x' == 1 {
tempfile e_trustw_round1_female
save `e_trustw_round1_female', replace
}
if `x' == 2 {
tempfile e_trustw_round2_female
save `e_trustw_round2_female', replace
}
restore
}

use workers, clear
forval x=1(1)2 {
preserve
replace trustw`x' = trustw`x'*100
collapse (mean) meantrustw = trustw`x' (sd) sdtrustw = trustw`x' (count) n = trustw`x', by(Young)
generate hitrustw = meantrustw + invttail(n-1,0.025)*(sdtrustw / sqrt(n))
generate lotrustw = meantrustw - invttail(n-1,0.025)*(sdtrustw / sqrt(n))
ge round = `x'
if `x' == 1 {
tempfile e_trustw_round1_young
save `e_trustw_round1_young', replace
}
if `x' == 2 {
tempfile e_trustw_round2_young
save `e_trustw_round2_young', replace
}
restore
}

use entrepreneurs, clear
forval x=1(1)2 {
preserve
replace expect`x' = expect`x'*10
drop if Sample == "Women" | Sample == "Young"
if `x' == 2 {
drop if allpositive == 1 | negative == 1
}
collapse (mean) meanexpect = expect`x' (sd) sdexpect = expect`x' (count) n = expect`x' /*, by(race ses) */
generate hiexpect = meanexpect + invttail(n-1,0.025)*(sdexpect / sqrt(n))
generate loexpect = meanexpect - invttail(n-1,0.025)*(sdexpect / sqrt(n))
ge round = `x'
gen type = 1
if `x' == 1 {
tempfile expect_round1
save `expect_round1', replace
}
if `x' == 2 {
tempfile expect_round2
save `expect_round2', replace
}
restore
}

use entrepreneurs, clear
forval x=1(1)2 {
preserve
replace trust`x'  = trust`x'*100
drop if Sample == "Women" | Sample == "Young"
if `x' == 2 {
drop if allpositive == 1 | negative == 1
}
collapse (mean) meantrust = trust`x' (sd) sdtrust = trust`x' (count) n = trust`x' /*, by(race ses) */
generate hitrust = meantrust + invttail(n-1,0.025)*(sdtrust / sqrt(n))
generate lotrust = meantrust - invttail(n-1,0.025)*(sdtrust / sqrt(n))
ge round = `x'
gen type = 1
if `x' == 1 {
tempfile trust_round1
save `trust_round1', replace
}
if `x' == 2 {
tempfile trust_round2
save `trust_round2', replace
}
restore
}

use `expect_round1', clear
append using `expect_round2'
append using `e_trustw_round1'
append using `e_trustw_round2'

label define roundcodes 1 "Round 1" 2 "Round 2"
label values round roundcodes

twoway (bar meanexpect type, barw(.5) lwidth(medium) lcolor(black) color(black*.7)) (bar meantrustw type, barw(.5) lwidth(medium) lcolor(black) color(black*.1)) (rcap loexpect hiexpect type, lcolor(black)) (rcap lotrustw hitrustw type, lcolor(black)), ///
by(round, note(" " "95% CI reported")) yscale(range(20)) ///
xtitle("") xtick(1(1)2) xscale(r(0.5 2.5)) xlabel(1 "Expected" 2 "Revealed", noticks nolabel) ytitle(% of workers who are trustworthy, size(small)) legend(row(2) order(1 "Entrepreneurs' expectations of workers' trustworthiness" 2 "Workers' revealed trustworthiness") size(medsmall)) 
graph export "ExpectReveal.png", as(png) replace

gen n_expect = n if meanexpect  != .
gen n_trustw = n if meantrustw != .

collapse meanexpect sdexpect meantrustw sdtrustw n_expect n_trustw, by(round)
gen t = (meanexpect - meantrustw)/((((sdexpect^2)/n_expect)+((sdtrust^2)/n_trustw))^(1/2)) /*t-statistic mentioned in the article*/
sort round
local t1 = t in 1
local t2 = t in 2
local df = n_expect - 1 + n_trustw - 1
di `t1'
di `t2'
di 2*ttail(`df', abs(`t1'))
di 2*ttail(`df', abs(`t2'))

************************************
******** FIGURE A.1 ****************
************************************

use wms.dta, clear

by countryname, sort: egen avgtalent2 = mean(talent2)
by countryname, sort: egen avgtalent3 = mean(talent3)

preserve
duplicates drop countryname, force

sort avgtalent2
gen id = _n

twoway (bar avgtalent2 id if continent  == "Africa", color(white) lcolor(black) lwidth(vthin)) ///
       (bar avgtalent2 id if continent == "Asia", color(black*.20) lcolor(black) lwidth(vvvthin))    ///
       (bar avgtalent2 id if continent == "Europe", color(black*.20) lcolor(black) lwidth(medthick)) ///   
       (bar avgtalent2 id if continent == "North America", color(black*.40)) ///
       (bar avgtalent2 id if continent == "South America", color(black*.80)) ///
       (bar avgtalent2 id if continent == "Oceania", color(black) ///
	   legend(order(1 "Africa" 2 "Asia" 3 "Europe" 4 "North America" 5 "South America" 6 "Oceania") row(2) size(small)) ///
	   xlabel(none) xtitle(" " "", margin(medium)) ytitle("Average score by country", size(vsmall) margin(small)) ///
	   text(1.83 1 "Greece", place(n)) ///
	   text(1.95 1 "|", place(s)) ///
	   text(2 1 "|", place(s)) ///
	   text(1.83 6 "Tanzania", place(n)) ///
	   text(1.95 5 "|", place(s)) ///
	   text(2 5 "|", place(s)) ///
	   text(2.28 6 "{bf:Ghana}", place(n)) ///
	   text(2.28 6 "|", place(s)) ///
	   text(2.23 6 "|", place(s)) ///
	   text(1.83 12 "Ethiopia", place(n)) ///
	   text(1.95 11 "|", place(s)) ///
	   text(2 11 "|", place(s)) ///
	   text(2.43 14 "Colombia", place(n)) ///
	   text(2.43 14 "|", place(s)) ///
	   text(2.38 14 "|", place(s)) ///
	   text(2.63 22 "India", place(n)) ///
	   text(2.63 22 "|", place(s)) ///
	   text(2.58 22 "|", place(s)) ///
	   text(1.83 24 "Canada", place(n)) ///
	   text(1.95 24 "|", place(s)) ///
	   text(2 24 "|", place(s)) ///
	   text(2.91 26.5 "China", place(n)) ///
	   text(2.99 28.75 "__", place(s)) ///
	   text(2.99 30.15 "___", place(s)) ///
	   text(2.94 31 "|", place(s)) ///
	   text(3.03 28.8 "Japan", place(n)) ///
	   text(3.122 31.1 "__", place(s)) ///
	   text(3.122 32.2 "___", place(s)) ///
	   text(3.072 33.05 "|", place(s)) ///
   	   text(1.83 32 "United States", place(n)) ///
	   text(1.95 34 "|", place(s)) ///
	   text(2 34 "|", place(s)) )

	   graph export "HighPerformanceCulture.png", replace width(1600) height(1200)
	   
capture drop id
sort avgtalent3
gen id = _n


twoway (bar avgtalent3 id if continent  == "Africa", color(white) lcolor(black) lwidth(vthin)) ///
       (bar avgtalent3 id if continent == "Asia", color(black*.20) lcolor(black) lwidth(vvvthin))    ///
       (bar avgtalent3 id if continent == "Europe", color(black*.20) lcolor(black) lwidth(medthick)) ///   
       (bar avgtalent3 id if continent == "North America", color(black*.40)) ///
       (bar avgtalent3 id if continent == "South America", color(black*.80)) ///
       (bar avgtalent3 id if continent == "Oceania", color(black) ///
	   legend(order(1 "Africa" 2 "Asia" 3 "Europe" 4 "North America" 5 "South America" 6 "Oceania") row(2) size(small)) ///
	   xlabel(none) xtitle(" " "", margin(medium)) ytitle("Average score by country", size(vsmall) margin(small)) ///
	   text(1.70 1 "Ethiopia", place(n)) ///
	   text(1.95 1 "|", place(s)) ///
	   text(2 1 "|", place(s)) ///
	   text(2.92 4 "Myanmar", place(n)) ///
	   text(2.92 4 "|", place(s)) ///
	   text(2.82 4 "|", place(s)) ///
	   text(1.70 8 "Tanzania", place(n)) ///
	   text(1.95 8 "|", place(s)) ///
	   text(2 8 "|", place(s)) ///
	   text(3.05 11 "{bf:Ghana}", place(n)) ///
	   text(3.05 11 "|", place(s)) ///
	   text(2.95 11 "|", place(s)) ///
	   text(1.70 13 "Kenya", place(n)) ///
	   text(1.95 13 "|", place(s)) ///
	   text(2 13 "|", place(s)) ///
	   text(3.10 15 "Nigeria", place(n)) ///
	   text(3.10 15 "|", place(s)) ///
	   text(3 15 "|", place(s)) ///
	   text(1.70 18 "Brazil", place(n)) ///
	   text(1.95 18 "|", place(s)) ///
	   text(2 18 "|", place(s)) ///
	   text(1.70 27 "Singapore", place(n)) ///
	   text(1.95 27 "|", place(s)) ///
	   text(2 27 "|", place(s)) ///
	   text(3.2 22 "China", place(n)) ///
	   text(3.2 22 "|", place(s)) ///
	   text(3.1 22 "|", place(s)) ///
	   text(3.33 28 "Germany", place(n)) ///
	   text(3.33 28 "|", place(s)) ///
	   text(3.23 28 "|", place(s)) ///
	   text(1.70 33 "Canada", place(n)) ///
	   text(1.95 33 "|", place(s)) ///
	   text(2 33 "|", place(s)) ///
	   text(3.93 31 "United States", place(n)) ///
	   text(3.93 34 "|", place(s)) ///
	   text(3.83 34 "|", place(s)) )
	   
	   graph export "RemovingPoorPerformers.png", replace width(1600) height(1200)

restore

************************************
******** FIGURE A.4 ****************
************************************

use "ethiopia_firm_survey.dta", clear

graph hbar, over(m_1) bar(1, lcolor(black) color(black*.6)) ytitle("%") name(PanelA, replace) title("All Firms", size(small))
graph hbar if l_1<5, over(m_1) bar(1, lcolor(black) color(black*.6)) ytitle("%") name(PanelB, replace) title("Small Firms (<5 employees)", size(small))
graph combine PanelA PanelB, row(2) title("Are there situations in your firm where closely monitoring workers is too difficult" "or costly, and you simply have to trust that workers will do" "a good job while they are not being monitored?" " ", size(medsmall)) 

graph export MonitoringSituations.png, as(png) replace

************************************
******** FIGURE A.5 ****************
************************************

use "ethiopia_firm_survey.dta", clear

preserve
keep m1_12*
collapse m1_12*
gen id = 1

rename m1_12a m1_12_1
rename m1_12b m1_12_2 
rename m1_12c m1_12_3
rename m1_12d m1_12_4
rename m1_12e m1_12_5
rename m1_12f m1_12_6
rename m1_12g m1_12_7

reshape long m1_12_, j(type) i(id)

label define typecodes 1 "Honesty" 2 "Trustworthiness" 3 "Practical Skills" 4 "Soft Skills" 5 "Numeracy" 6 "Literacy" 7 "Theoretical Skills" 
label values type typecodes

graph hbar (mean) m1_12_, over(type) bar(1, lcolor(black) color(black*.6)) ytitle("Average Score (out of 10)", size(small)) name(PanelA, replace) title("All Firms", size(small))
restore

preserve
keep if l_1 < 5
keep m1_12*
collapse m1_12*
gen id = 1

rename m1_12a m1_12_1
rename m1_12b m1_12_2 
rename m1_12c m1_12_3
rename m1_12d m1_12_4
rename m1_12e m1_12_5
rename m1_12f m1_12_6
rename m1_12g m1_12_7

reshape long m1_12_, j(type) i(id)

label define typecodes 1 "Honesty" 2 "Trustworthiness" 3 "Practical Skills" 4 "Soft Skills" 5 "Numeracy" 6 "Literacy" 7 "Theoretical Skills" 
label values type typecodes

graph hbar (mean) m1_12_, over(type) bar(1, lcolor(black) color(black*.6)) ytitle("Average Score (out of 10)", size(small)) name(PanelB, replace) title("Small Firms (<5 employees)", size(small))

graph combine PanelA PanelB, row(2) title("On a scale from 0 to 10, where 0 means “not important at all” and 10 means “extremely important”," "how important are the following worker qualities for your firm?" " ", size(small)) 
graph export MostImportantTraits.png, as(png) replace

restore

************************************
******** FIGURE A.6 ****************
************************************

use "ethiopia_firm_survey.dta", clear

label define m_2codes 1 "Not Monitored/Not Incentivised" 2 "Monitored/Incentivised"
label values m_2 m_2codes 

graph hbar, over(m_2) bar(1, lcolor(black) color(black*.6)) ytitle("%") name(PanelA, replace) title("All Firms", size(small))
graph hbar if l_1<5, over(m_2) bar(1, lcolor(black) color(black*.6)) ytitle("%") name(PanelB, replace)  title("Small Firms (<5 employees)", size(small))
graph combine PanelA PanelB, row(2) title("In order to decide if you can trust a worker," "would you rather want to learn about how s/he performed when...", size(medsmall))
graph export MostValuableInfo.png, as(png) replace

************************************
******** FIGURE A.7 ****************
************************************

use entrepreneurs.dta, clear
drop if Pilot == 1

gen Q3_0 = (Q3 == 0)
gen Q3_1 = (Q3 == 1 | Q3 == 2)
gen Q3_3 = (Q3 >= 3 & Q3 <= 5)
gen Q3_5 = (Q3 > 5 & Q3 != .)

preserve
keep if Q3 != .
keep Q3_*
collapse Q3_*
gen id = 1
reshape long Q3_, j(type) i(id)

replace type = 2 if type == 3
replace type = 3 if type == 5

replace type = type + .5

twoway (bar Q3_ type, barw(.5) lwidth(medium) lcolor(black) color(black*.6)), yscale(range(0 .8)) ylabel(.1(.1).8) ytick(.1(.1).8) xtitle(" " "Number of Workers Employed", size(small)) xtick(0.5(1)3.5) xscale(r(0 4)) xlabel(0.5 "0" 1.5 "1-2" 2.5 "3-5" 3.5 ">5", noticks) ytitle("Share of Entrepreneurs" " ", size(small)) 
graph export NumEmployeesHired.png, as(png) replace
restore

************************************
******** FIGURE A.8 ****************
************************************

use `trust_round1', clear
append using `trust_round2'
append using `e_trustw_round1'
append using `e_trustw_round2'

label define roundcodes 1 "Round 1" 2 "Round 2"
label values round roundcodes

twoway (bar meantrust type, barw(.5) lwidth(medium) lcolor(black) color(black*.7)) (bar meantrustw type, barw(.5) lwidth(medium) lcolor(black) color(black*.1)) (rcap lotrustw hitrustw type, lcolor(black)) (rcap lotrust hitrust type, lcolor(black)), ///
by(round, note(" " "95% CI reported")) yscale(range(20)) ///
xtitle("") xtick(1(1)2) xscale(r(0.5 2.5)) xlabel(1 "Trust" 2 "Trustworthiness", noticks nolabel) ytitle("% of entrepreneurs who trust / workers who are trustworthy", size(vsmall)) legend(row(2) order(1 "Entrepreneurs' revealed trust" 2 "Workers' revealed trustworthiness") size(medsmall))
graph export "RevealTrustTrustw.png", as(png) replace

gen n_trustw = n if meantrustw  != .
gen n_trust = n if meantrust != .

collapse meantrustw sdtrustw meantrust sdtrust n_trustw n_trust, by(round)
gen t = (meantrustw - meantrust)/((((sdtrustw^2)/n_trustw)+((sdtrust^2)/n_trust))^(1/2)) /*t-statistic mentioned in the article*/
sort round
local t1 = t in 1
local t2 = t in 2
local df = n_trustw - 1 + n_trust - 1
di `t1'
di `t2'
di 2*ttail(`df', abs(`t1'))
di 2*ttail(`df', abs(`t2'))

************************************
******** FIGURE A.9 *****************
************************************

use entrepreneurs.dta, clear
drop if Pilot == 1

preserve
replace expect1 = expect1*10
replace expect2 = expect2*10
cumul expect1, g(cumul_expect1)
cumul expect2, g(cumul_expect2)
by expect1, sort: egen maxcumul1 = max(cumul_expect1)
by expect2, sort: egen maxcumul2 = max(cumul_expect2)
twoway (bar maxcumul1 expect1, barw(8) lwidth(medium) lcolor(black) color(black*.7) ytitle("Cumul. share of entrepreneurs", size(medsmall)) title(Round 1, size(mesmall)) xtitle(" " "% of workers expected trustworthy", size(small)) xlabel(0(10)100) name(cumul1, replace)) 
twoway (bar maxcumul2 expect2, barw(8) lwidth(medium) lcolor(black) color(black*.7) ytitle("Cumul. share of entrepreneurs", size(medsmall)) title(Round 2, size(mesmall)) xtitle(" " "% of workers expected trustworthy", size(small)) xlabel(0(10)100) name(cumul2, replace))
graph combine cumul1 cumul2, col(2)
graph export "Cumul.png", as(png) replace
restore

************************************
******** FIGURE A.10 ***************
************************************

use `trust_round1', clear
append using `trust_round2'
append using `e_expect_round1'
append using `e_expect_round2'

label define roundcodes 1 "Round 1" 2 "Round 2"
label values round roundcodes

twoway (bar meantrust type, barw(.5) lwidth(medium) lcolor(black) color(black*.7)) (bar meanexpect type, barw(.5) lwidth(medium) lcolor(black) color(black*.1)) (rcap loexpect hiexpect type, lcolor(black)) (rcap lotrust hitrust type, lcolor(black)), ///
by(round, note(" " "95% CI reported")) yscale(range(20)) ///
xtitle("") xtick(1(1)2) xscale(r(0.5 2.5)) xlabel(1 "Revealed" 2 "Expected", noticks nolabel) ytitle("% of entrepreneurs who trust (hire)", size(small)) legend(row(2) order(1 "Entrepreneurs' revealed trust" 2 "Workers' expectations of employers' trust") size(medsmall))
graph export "ExpectEe.png", as(png) replace

gen n_expect = n if meanexpect  != .
gen n_trust = n if meantrust != .

collapse meanexpect sdexpect meantrust sdtrust n_expect n_trust, by(round)
gen t = (meanexpect - meantrust)/((((sdexpect^2)/n_expect)+((sdtrust^2)/n_trust))^(1/2)) /*t-statistic mentioned in the article*/
sort round
local t1 = t in 1
local t2 = t in 2
local df = n_expect - 1 + n_trust - 1
di `t1'
di `t2'
di 2*ttail(`df', abs(`t1'))
di 2*ttail(`df', abs(`t2'))

************************************
******** FIGURE A.11 ***************
************************************

preserve
use `e_trustw_round1_female', clear
append using `e_trustw_round2_female'
label define roundcodes 1 "Round 1" 2 "Round 2"
label values round roundcodes
graph twoway (bar meantrustw Male if round == 1, barw(.35) lwidth(medthick) lcolor(black) color(black*.7) xscale(r(-0.5 1.5)) xlabel(0 "Female" 1 "Male") xtitle("") ///
ytitle(% of female/male workers, size(small)) legend(off) yscale(range(20)) ylabel(20 40 60 80 100) note(" " "95% CI reported, Round 1")) (rcap lotrustw hitrustw Male if round == 1, lcolor(black)) 
graph export "ExpectReveal_FEMALE.png", as(png) replace

keep if round == 1
keep meantrustw sdtrustw n Male
gen id = 1

reshape wide meantrustw sdtrustw n, j(Male) i(id)
gen t = (meantrustw0 - meantrustw1)/((((sdtrustw0^2)/n0)+((sdtrustw1^2)/n1))^(1/2)) /*t-statistic mentioned in the article*/

local t = t
local df = n0 - 1 + n1 - 1
di 2*ttail(`df', abs(`t'))
restore

************************************
******** FIGURE A.12 ***************
************************************

preserve
use `e_trustw_round1_young', clear
append using `e_trustw_round2_young'
label define roundcodes 1 "Round 1" 2 "Round 2"
label values round roundcodes
replace Young = abs(Young-1)  /*ONLY FOR GRAPHING PURPOSES*/
graph twoway (bar meantrustw Young if round == 1, barw(.35) lwidth(medthick) lcolor(black) color(black*.7) xscale(r(-0.5 1.5)) xlabel(0 "Younger  (< 25)" 1 "Older (>= 25)") xtitle("") ///
ytitle(% of younger/older workers, size(small)) legend(off) yscale(range(20)) ylabel(20 40 60 80 100) note(" " "95% CI reported, Round 1")) (rcap lotrustw hitrustw Young if round == 1, lcolor(black)) 
graph export "`figures'ExpectReveal_YOUNG.png", as(png) replace

keep if round == 1
keep meantrustw sdtrustw n Young
gen id = 1

reshape wide meantrustw sdtrustw n, j(Young) i(id)
gen t = (meantrustw0 - meantrustw1)/((((sdtrustw0^2)/n0)+((sdtrustw1^2)/n1))^(1/2)) /*t-statistic mentioned in the article*/

local t = t
local df = n0 - 1 + n1 - 1
di 2*ttail(`df', abs(`t'))
restore

************************************
******** FIGURE A.13 ***************
************************************

use "ethiopia_firm_survey.dta", clear

replace m_6 = m_6*10
histogram m_6, discrete xtitle(" " "Expected Trustworthiness" "(% of trustworthy workers)")
graph export DistExpTrustw.png, as(png) replace

************************************
******** TABLES ********************
************************************

************************************
******** TABLE 1 *******************
************************************

use entrepreneurs, clear
drop if Pilot == 1

gen Employed = (Student == 0 & Unemployed == 0  & Occupation != "Retired" & Occupation != "None")
sum Age Male Married NoSchoo Primary LoSec UpSec Tert Employed TraderAgric ManufacturerConstr Service UnknownSelf Q3

use workers, clear
drop if Pilot == 1

gen Employed = (Student == 0 & Unemployed == 0  & Occupation != "Retired" & Occupation != "None")
sum Age Male Married NoSchoo Primary LoSec UpSec Tert Employed

************************************
******** TABLE 2 *******************
************************************

use entrepreneurs, clear
drop if Pilot == 1

reg expect1 syoung swomen Age Male LoSecondary UpSecondary Tertiary Married Unemployed before EarlyMorn Aftern, cluster(SessionID)
reg expect1 syoung swomen Age Male LoSecondary UpSecondary Tertiary Married Unemployed before EarlyMorn Aftern if Male == 1, cluster(SessionID)
reg expect1 syoung swomen Age Male LoSecondary UpSecondary Tertiary Married Unemployed before EarlyMorn Aftern if Male == 0, cluster(SessionID)

************************************
******** TABLE 3 *******************
************************************

label variable negative "Neg Sig"
label variable positive "Pos Sig"
label variable allpositive "Pos Sig"
label variable wpositive "Pos Sig (F)"
label variable ypositive "Pos Sig (Y)"
label variable t1 "T1 Homog"
label variable t2 "T1 Heter"

gen PersChars = .
label variable PersChars "Personal Char.s"

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1), cluster(SessionID)
test _b[negative] - _b[positive] = 0                                                    

reg expect2 expect1 negative positive wpositive ypositive t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before, cluster(SessionID)
test _b[negative] - _b[positive] = 0                                                    

************************************
******** TABLE 4 *******************
************************************

reg trust2 expect2, cluster(SessionID) 
reg trust2 expect2 loss before Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern, cluster(SessionID) 
ivregress 2sls trust2 loss before Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern (expect2 = negative positive allpositive t1 t2), cluster(SessionID) first

*ADDITIONAL ROBUSTNESS TESTS ON THE RESULTS IN TABLE 4

*STANDARD IV ESTIMATES - ALL SESSIONS
ivreg2 trust2 loss before Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern  (expect2 = negative positive allpositive t1 t2), cluster(SessionID) first

*LIML - ALL SESSIONS
ivreg2 trust2 loss before Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern  (expect2 = negative positive allpositive t1 t2), cluster(SessionID) first liml

*STANDARD IV ESTIMATES - EXCL. SESSIONS WITH HETEROG SIGNALS
ivreg2 trust2 loss before Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern  (expect2 = negative positive t1) if (t0 == 1 | t1 == 1), cluster(SessionID) first

************************************
******** TABLE 5 *******************
************************************

reg expect1 Q3, cluster(SessionID) 
reg trust1 Q3, cluster(SessionID)

reg expect1 Q3 Male EducYs Age Married Unemployed before EarlyMorn Aftern, cluster(SessionID) 
reg trust1 Q3 Male EducYs Age Married Unemployed before EarlyMorn Aftern, cluster(SessionID)

************************************
******** TABLE A.1 *****************
************************************

gen Employed = (Unemployed == 0 & Student == 0)
gen t1_new = t1 | t2
gen t2_new = (Sample == "Women" | Sample == "Young")

capture erase temp.dta
preserve
clear
*set obs 1
gen var1 = ""
save temp.dta
restore

foreach var in Male Age EducYs Married Employed TraderAgric ManufacturerConstr Service UnknownSelf Q3 {

qui ttest `var', by(t1_new)

local mu1_1 = round(`r(mu_1)',0.01)
local mu1_2 = round(`r(mu_2)',0.01)
local p1 = round(`r(p)',0.001)

ttest `var', by(t2_new)

local mu2_1 = round(`r(mu_1)',0.01)
local mu2_2 = round(`r(mu_2)',0.01)
local p2 = round(`r(p)',0.001)

preserve
clear
set obs 1

gen var1 = "`var' &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"

if "`var'" == "EducYs" {
replace var1 = "Education (years) &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}
if "`var'" == "TraderAgric" {
replace var1 = "Sect: Trading &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}
if "`var'" == "ManufacturerConstr" {
replace var1 = "Sect: Manufacturing &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}
if "`var'" == "Service" {
replace var1 = "Sect: Services &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}
if "`var'" == "UnknownSelf" {
replace var1 = "Sect: Unspecified &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}
if "`var'" == "Q3" {
replace var1 = "No. Employees &&  `mu1_1'   &  `mu1_2'   &  `p1'   && & `mu2_1'  & `mu2_2'  & `p2'  \\"
}

tempfile temp
save `temp', replace

use temp.dta, clear
append using `temp'
save temp, replace
sleep 200
li
restore
}

capture erase temp.dta

************************************
******** TABLE A.2 *****************
************************************

qui reg expect1 Age Female LowEduc, cluster(SessionID)
capture drop sample
gen sample = (e(sample) == 1)

reg expect1 Age if sample, cluster(SessionID)
reg expect1 Female if sample, cluster(SessionID)
reg expect1  LowEduc if sample, cluster(SessionID)
reg expect1 Age Female LowEduc if sample, cluster(SessionID)

************************************
******** TABLE A.3 *****************
************************************

use workers, clear

gen RoundSession = SessionID

qui reg trustw1 Age Female Tertiary Unemployed NoSchool
gen sample = (e(sample) == 1)

reg trustw1 Age if sample, cluster(RoundSession)
reg trustw1 Female if sample, cluster(RoundSession)
reg trustw1  NoSchoo Primary LoSec Tert  if sample, cluster(RoundSession)
reg trustw1 Unemployed if sample, cluster(RoundSession)
reg trustw1 Age Female NoSchoo Primary LoSec Tert Unemployed, cluster(RoundSession)

drop sample

************************************
******** TABLE A.4 *****************
************************************

preserve

gen SurveyIDnew = _n
keep trustw1 trustw2 expect1 expect2 SurveyIDnew Age Male Primary LoSec UpSec Tertiary Unemployed Married RoundSession before EarlyMorn Aftern
reshape long trustw expect, i(SurveyIDnew) j(round)
gen Round2 = (round == 2)

reg trustw expect, cluster(RoundSession) 
reg trustw expect Age Male LoSecondary UpSecondary Tertiary  Married Unemployed before EarlyMorn Aftern, cluster(RoundSession) 
probit trustw expect, cluster(RoundSession) 
probit trustw expect Age Male LoSecondary UpSecondary Tertiary Married Unemployed before EarlyMorn Aftern, cluster(RoundSession) 
dprobit trustw expect Age Male LoSecondary UpSecondary Tertiary Married Unemployed before EarlyMorn Aftern, cluster(RoundSession) 

restore

************************************
******** TABLE A.5 *****************
************************************

use entrepreneurs, clear
drop if Pilot == 1

reg expect2 expect1 negative positive wpositive ypositive t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before, cluster(SessionID)

gen pos = wpositive | ypositive

*AGE
gen AgeAboveMed = (Age >= 37)

reg expect2 expect1 negative positive pos t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if AgeAboveMed == 0, cluster(SessionID)
reg expect2 expect1 negative positive pos t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if AgeAboveMed == 1, cluster(SessionID)

*EDUCATION
gen EducAboveMed = (EducYs >= 12)

reg expect2 expect1 negative positive pos t1 t2 Age Male Married Unemployed EarlyMorn Aftern before if EducAboveMed == 0, cluster(SessionID)
reg expect2 expect1 negative positive pos t1 t2 Age Male Married Unemployed EarlyMorn Aftern before if EducAboveMed == 1, cluster(SessionID)

test _b[negative] - _b[positive] = 0

************************************
******** TABLE A.6 *****************
************************************

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1), cluster(SessionID)

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1) & expect1 <= 7, cluster(SessionID)
test negative = positive

reg expect2 expect1 negative positive wpositive ypositive t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before, cluster(SessionID)
	
reg expect2 expect1 negative positive wpositive ypositive t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if expect1 <= 7, cluster(SessionID)
test negative = positive

************************************
******** TABLE A.7 *****************
************************************

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1), cluster(SessionID)

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1) & expect1 <= 7 & expect1 >= 3, cluster(SessionID)
test negative = positive

reg expect2 expect1 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before if (t0 == 1 | t1 == 1) & expect1 <= 6 & expect1 >= 4, cluster(SessionID)
test negative = positive

************************************
******** TABLE A.8 *****************
************************************

use entrepreneurs, clear
drop if Pilot == 1
	
preserve
keep ent_id SessionID trust1 trust2 expect1 expect2 loss before Age Male EducYs Primary LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern
reshape long trust expect, i(ent_id SessionID loss before Age Male EducYs Married Unemployed) j(round)
label variable expect "E[Trustw]"
tab round, g(Round)
label variable Round2 "Round 2"
tostring round, replace
gen RoundSession = SessionID + round

reg trust expect Round2, cluster(RoundSession) 
reg trust expect loss Age Male LoSecondary UpSecondary Tertiary  Married Unemployed before Round2 EarlyMorn Aftern, cluster(RoundSession) 
probit trust expect Round2, cluster(RoundSession) 
probit trust expect loss Age Male LoSecondary UpSecondary Tertiary Married Unemployed before Round2 EarlyMorn Aftern, cluster(RoundSession) 
dprobit trust expect loss Age Male LoSecondary UpSecondary Tertiary Married Unemployed before Round2 EarlyMorn Aftern, cluster(RoundSession) 
restore

************************************
******** TABLE A.9 *****************
************************************

reg trust2 negative positive t1 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before loss if (t0 == 1 | t1 == 1), cluster(SessionID)

reg trust2 negative positive wpositive ypositive t1 t2 Age Male LoSecondary UpSecondary Tertiary Married Unemployed EarlyMorn Aftern before loss, cluster(SessionID)

************************************
******** TABLE A.10 ****************
************************************

use ethiopia_firm_survey.dta, clear

preserve

gen negative = (m_7_2 != .)

gen update = (m_7_1 < 3 | m_7_2 < 3)
gen strong_update = (m_7_1 < 2 | m_7_2 < 2)

reg update negative
reg strong_update negative

reg update negative if l_1 < 5
reg strong_update negative  if l_1 < 5

restore

************************************
******** TABLE A.11 ****************
************************************

preserve

drop if m_6 > 7

gen negative = (m_7_2 != .)

gen update = (m_7_1 < 3 | m_7_2 < 3)
gen strong_update = (m_7_1 < 2 | m_7_2 < 2)

reg update negative
reg strong_update negative

reg update negative if l_1 < 5
reg strong_update negative  if l_1 < 5

restore

************************************
******** TABLE A.12 ****************
************************************

preserve
drop if m_6 > 8 | m_6 < 2
gen negative = (m_7_2 != .)
gen strong_update = (m_7_1 < 2 | m_7_2 < 2)

reg strong_update negative

restore

preserve
drop if m_6 > 7 | m_6 < 3
gen negative = (m_7_2 != .)
gen strong_update = (m_7_1 < 2 | m_7_2 < 2)

reg strong_update negative

restore

preserve
drop if m_6 > 6 | m_6 < 4
gen negative = (m_7_2 != .)
gen strong_update = (m_7_1 < 2 | m_7_2 < 2)

reg strong_update negative

restore

************************************
******** TABLE A.13 ****************
************************************

use entrepreneurs, clear
drop if Pilot == 1

preserve
replace Q3 = ln(Q3)

reg expect1 Q3, cluster(SessionID) 
reg trust1 Q3, cluster(SessionID)
reg expect1 Q3 Male EducYs Age Married Unemployed before EarlyMorn Aftern, cluster(SessionID) 
reg trust1 Q3 Male EducYs Age Married Unemployed before EarlyMorn Aftern, cluster(SessionID)

restore

************************************
******** TABLE A.14 ****************
************************************

qui reg trust1 Q3 Male EducYs Age Married Unemployed before EarlyMorn Aftern, cluster(SessionID)
gen insample = e(sample)

capture drop Q3dum
gen Q3dum = Q3 > 0

reg expect1 Q3dum if insample, cluster(SessionID)
reg expect1 Q3dum if insample & Literacy == "R & W", cluster(SessionID)
reg expect1 Q3dum if insample & Tertiary, cluster(SessionID)

exit